
package org.argeproje.resim.proc.math;

import java.awt.image.renderable.ParameterBlock;

import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;

import org.argeproje.resim.proc.ConnectionRule;
import org.argeproje.resim.proc.data.Data;
import org.argeproje.resim.proc.data.ImageDA;



public class ImageLogicalPR extends LogicalPR {
	protected void setConnectionRules(ConnectionRule connRule){
		connRule.addInType(ImageDA.class, 0);
		connRule.addInType(ImageDA.class, 1);
		connRule.addOutType(ImageDA.class);
	}
	public Data process() {
		ParameterBlock pb = new ParameterBlock();
		PlanarImage im = getInputAsPlanarImage();
		pb.addSource(im);
	    pb.addSource(getInputAsPlanarImage(1));
	    PlanarImage imout = null;
		switch (getParamOpType()) {
		case MathPR.AND:
			imout = JAI.create("and", pb, null);
			break;
		case MathPR.OR:
			imout = JAI.create("or", pb, null);
			break;
		case MathPR.XOR:
			imout = JAI.create("xor", pb, null);
			break;
		default:
			break;
		}
		ImageDA out = new ImageDA(imout);
		setOutput(out);
		return getOutput();
	}
}
